import socket,time

class FeiQ_test():
    def pressure_test(self):
        for i in range(1,2):
            mysocket = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)   # 实例化socket对象
            mysocket.connect(("192.168.2.120",2425))   #建立连接
            # IPMSG的报文格式：版本号：包编号：发送者姓名：发送者主机名：命令字：附加信息
            packetId = str(time.time())
            name = 'iio'
            host = 'localhost'
            command = str(0x00000020)
            content = 'This is the message from python'
            msg = '1.0:'+packetId+':'+name+':'+host+':'+command+':'+content
            mysocket.send(msg.encode('GBK'))    #发送消息
            mysocket.close()   #断开连接

    print("运行完成.")

if __name__ == '__main__':
    t = FeiQ_test()
    t.pressure_test()